package webcrawler;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class ChinaProvince {
    private String name;
    private String code;
    private List<ChinaCity> cityList = new ArrayList<>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public List<ChinaCity> getCityList() {
        return cityList;
    }

    public void setCityList(List<ChinaCity> cities) {
        if(cities == null) throw new RuntimeException("ChinaCity list is null");
        this.cityList = cities;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ChinaProvince that = (ChinaProvince) o;
        return name.equals(that.name) &&
                code.equals(that.code) &&
                Objects.equals(cityList, that.cityList);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, code, cityList);
    }

    @Override
    public String toString() {
        return "ChinaProvince{" +
                "name='" + name + '\'' +
                ", code='" + code + '\'' +
                '}';
    }
}
